package com.dongdong.bookstore.module.common.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Objects;

/**
 * @author chiangkai
 * @date 2021-11-05
 * @email chiangkk@163.com
 */
@Data
public class SliceFile {
    @NotEmpty
    @ApiModelProperty("当前分片大小")
    @NotEmpty
    private int chunkSize;
    @ApiModelProperty("分片数量")
    @NotEmpty
    private int chunkTotal;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SliceFile sliceFile = (SliceFile) o;

        return index == sliceFile.index;
    }

    @Override
    public int hashCode() {
        return index;
    }

    @ApiModelProperty("当前分片下标")
    @NotEmpty
    private int index;
    @ApiModelProperty("分片Hash")
    @NotEmpty
    private String chunkHash;

    @ApiModelProperty("文件名称")
    @NotEmpty
    private String fileName;
    @ApiModelProperty(value = "整个文件大小")
    @NotEmpty
    private String fileHash;
    @ApiModelProperty(value = "总文件大小")
    @NotEmpty
    private Long fileSize;

    @ApiModelProperty("设置的分片大小")
    @NotEmpty
    private int chunkOneSize;

    @ApiModelProperty("上传的文件分片")
    @NotNull(message = "文件上传失败")
    MultipartFile file;

}
